package com.jifen.mch.controller;

import com.jifen.common.CommonResult;
import com.jifen.common.Result;
import com.jifen.goods.vo.GoodsParam;
import com.jifen.mch.entity.Mch;
import com.jifen.mch.service.MchService;
import com.jifen.mch.vo.MchParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jf/{version}/mch")
public class MchController {

    @Autowired
    MchService mchService;

    /**
     * 获取商户消费二维码
     * @param token
     * @param amount
     * @return
     */
    @RequestMapping("/getConsumeQrcode")
    @ResponseBody
    public Result getConsumeQrcode(String token, double amount) {
        return CommonResult.createSuccessResult(mchService.getConsumeQrcode(token, amount));
    }

    /**
     * 获取超市二维码内容
     * @param token
     * @param id
     * @param jifen
     * @return
     */
    @RequestMapping("/smarket/getConsumeQrcode")
    @ResponseBody
    public Result getSmarketQrCode(String token, int id, int jifen) {
        return CommonResult.createSuccessResult(mchService.getSmarketQrCode(token, id, jifen));
    }

    /**
     * 积分明细
     * @param param
     * @return
     */
    @RequestMapping("/getJifenDetail")
    @ResponseBody
    public Result getJifenDetail(MchParam param) {
        return CommonResult.createSuccessResult(mchService.getJifenDetail(param));
    }

    /**
     * 查询商超
     * @param param
     * @return
     */
    @RequestMapping("/search")
    @ResponseBody
    public Result selectMch(MchParam param) {
        return CommonResult.createSuccessResult(mchService.searchMch(param));
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @RequestMapping("/detail")
    @ResponseBody
    public Result detail(int id) {
        return CommonResult.createSuccessResult(mchService.detail(id));
    }

    /**
     * 获取行业
     * @return
     */
    @RequestMapping("/getIndustry")
    @ResponseBody
    public Result getIndustry() {
        return CommonResult.createSuccessResult(mchService.getIndustry());
    }

    /**
     * 修改商家信息
     * @param token
     * @param mchInfo
     * @return
     */
    @RequestMapping("/modifyMch")
    @ResponseBody
    public Result modifyMch(String token, Mch mchInfo){
        mchService.modifyMch(token, mchInfo);
        return CommonResult.createSuccessResult();
    }

    /**
     * 账单
     * @param param
     * @return
     */
    @RequestMapping("/getBill")
    @ResponseBody
    public Result getBill(MchParam param) {
        return CommonResult.createSuccessResult(mchService.bill(param));
    }

}
